/**
 * @(#)SystemLogTag.java Jan 6, 2010
 *   
 * Copyright  (c) 2009-2010 Wilmar IT Service,  Inc.   
 * All  rights  reserved.   
 * TODO
 */

package com.wilmar.process.web.taglibs;

import javax.servlet.jsp.JspWriter;

import com.wilmar.process.core.ProcessSystemDeclareKeys;

/**
 * @author makubex Email:makubexnet@gmail.com
 * @version 1.0.0
 */
public class SystemLogoTag extends ProcessTagSupport {

	/**
	 * @serialField
	 */
	private static final long serialVersionUID = 8244604494081022426L;

	private String height;
	private String width;

	/**
	 * @see org.springframework.web.servlet.tags.RequestContextAwareTag#doStartTagInternal()
	 */
	protected int doStartTagInternal() throws Exception {
		String c_height = ProcessSystemDeclareKeys.DEFAULT_LOGO_HEIGHT;
		if (this.height != null && this.height.trim().length() != 0)
			c_height = this.height;
		String c_width = ProcessSystemDeclareKeys.DEFAULT_LOGO_WIDTH;
		if (this.width != null && this.width.trim().length() != 0)
			c_width = this.width;
		StringBuffer html = new StringBuffer();
		html.append("<a href=\"");
		html.append(super.getContextPath());
		html.append("\" >");
		html.append("<img width=\"");
		html.append(c_width);
		html.append("\" height=\"");
		html.append(c_height);
		html.append("\" border=\"0\" src=\"");
		html.append(super.getContextPath());
		html.append(ProcessSystemDeclareKeys.SYSTEM_LOGO);
		html.append("\" ");
		html.append("/>");
		html.append("</a>");
		JspWriter outer = this.getOut();
		outer.write(html.toString());
		return SKIP_BODY;
	}

	/**
	 * @return the height
	 */
	public String getHeight() {
		return height;
	}

	/**
	 * @param height
	 *            the height to set
	 */
	public void setHeight(String height) {
		this.height = height;
	}

	/**
	 * @return the width
	 */
	public String getWidth() {
		return width;
	}

	/**
	 * @param width
	 *            the width to set
	 */
	public void setWidth(String width) {
		this.width = width;
	}

}
